<template>
  <!-- header -->
  <div class="app">
    <van-nav-bar
      :title="title"
      left-text="返回"
      right-text="按钮"
      left-arrow
      @click-left="onClickLeft"
    />
    <!-- main -->
    <router-view></router-view>
    <!-- footer -->
    <van-tabbar v-model="active" v-if="$route.meta.isShow">
      <van-tabbar-item icon="home-o" to="/home"></van-tabbar-item>
      <van-tabbar-item icon="friends-o" to="/friends"></van-tabbar-item>
      <van-tabbar-item icon="cart-o" badge="6" to="/cart"></van-tabbar-item>
      <van-tabbar-item icon="search" to="/search"></van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
export default {
  data() {
    return {
      title: this.$route.meta.title,
      active: 0
    }
  },
  watch: {
    '$route.meta.title'(newval, oldval) {
      console.log(newval)
      this.title = newval
    }
  },
  methods: {
    onClickLeft() {
      // console.log(this.$router)
      this.$router.go(-1)
    }
  }
}
</script>
<style lang="scss" scoped>
</style>
